<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {

	/*系统首页*/
    public function index(){
        /*轮播图*/
        $document=M("document");
        $map['status']=array('eq',1);
        $map['category_id']=array('eq',59);
        $banner_data=$document->join("ot_document_banner on ot_document.id=ot_document_banner.id")->field("ot_document.*,ot_document_banner.links")->where($map)->order("level desc,ot_document.id desc")->select();
        $this->assign("banner_data",$banner_data);

        /*公司简介*/
        $document=D("Document");
        $cate=$document->lists(101);
        $gsjj=$document->detail($cate[0]['id']);
        $this->assign("gsjj",$gsjj);
        //print_r($gsjj);exit;
        $category=D("Category");
        $product_cate=$category->getSameLevel(75);
        $this->assign("product_cate",$product_cate);

       /*导航*/
        $Channel=D("Channel");
        $channel_list=$Channel->lists();

        /*合作单位*/
        $cooperative=$document->lists(93);

        $document_banner=M("document_banner");
        foreach($cooperative as $key=>$val){
            $cooperative[$key]['links']=$document_banner->where("`id`=".$val['id'])->getField("links");
        }
        /*合作项目*/
        $hzxm =$document->sub_document_page(579,4);
        $this->assign("hzxm",$hzxm);

        $this->assign("cooperative",$cooperative);

        $cate_list[0]=$category->info(111);
        $cate_list[1]=$category->info(112);
        $this->assign("cate_list",$cate_list);
        $this->assign("channel_list",$channel_list);
        $this->display();
    }
    public function detail(){
        $id=I("get.id",0,"int");
        $document=D("Document");
        $data_info=$document->detail($id);//分类信息
        $this->assign("data_info",$data_info);
        $this->display();
    }

}